#ifndef XGE_UNITTEST_ZIPFS_H_
#define XGE_UNITTEST_ZIPFS_H_
#include "xfsm.h"
#include "xassert.h"
#include <stdio.h>

using xge::ArchivePtr;
using xge::FilePtr;
using xge::DirPtr;
using xge::FileSystemPtr;
using xge::FileSystemManager;

UNIT_TEST(ZIPFS,Case1) {
  // testing the zip file system
  FileSystemPtr zip_fs = FileSystemManager::GetFileSystem(GetZipFileSystemName());
  XASSERT( !zip_fs.Null() );
  // testing the internal implementation
  ArchivePtr zip_arc = zip_fs->LoadArchive( _xT("Test.zip") );
  XASSERT( !zip_arc.Null() );
  // get this archive and load the archive inside it
  ArchivePtr sub_arc = zip_arc->LoadArchive( _xT("d2") );
  XASSERT( !sub_arc.Null() );
  // get the file inside it
  ArchivePtr sub_arc2 = sub_arc->LoadArchive( _xT("d2") );
  XASSERT( !sub_arc2.Null() );

  FilePtr file = zip_arc->LoadFile( _T("readme.txt") );
  XASSERT( !file.Null() );
  size_t length = file->Length();

  char *buffer = (char*)malloc( length+1 );

  file->Load( buffer, length );

  buffer[length] = 0;

  MessageBoxA(NULL,buffer,"Caption",MB_OK);

  free(buffer);

  ::getchar();

}



#endif 